package cn.dong.edu.controller.api;

import cn.dong.api.domain.CommonResult;
import cn.dong.edu.domain.Course;
import cn.dong.edu.domain.Teacher;
import cn.dong.edu.service.CourseService;
import cn.dong.edu.service.TeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("/api/edu/index")
@Slf4j
@RestController
public class ApiIndexController {

    @Autowired
    private CourseService courseService;

    @Autowired
    private TeacherService teacherService;


    /**
     * 获取首页推荐数据
     * @return
     */
    @GetMapping("/getHotData")
    public CommonResult<Map<String, Object>> getHotData(){
        List<Course> list = courseService.getHotCourse();
        List<Teacher> list2 = teacherService.getHotTeacher();
        // 返回结果
        Map<String, Object> map = new HashMap<String, Object>(2);
        map.put("hotCourses", list);
        map.put("hotTeachers", list2);
        return CommonResult.ok().data(map);
    }

}
